```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java网络编程：URL与HttpURLConnection详解</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
            color: white;
        }
        .code-block {
            background-color: #2d3748;
            color: #e2e8f0;
            border-radius: 0.5rem;
            padding: 1.5rem;
            position: relative;
        }
        .code-block pre {
            margin: 0;
            overflow-x: auto;
        }
        .code-copy {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            color: #a0aec0;
            cursor: pointer;
            transition: all 0.2s;
        }
        .code-copy:hover {
            color: white;
        }
        .section-title {
            position: relative;
            padding-left: 1.5rem;
        }
        .section-title:before {
            content: "";
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            height: 70%;
            width: 0.25rem;
            background: linear-gradient(to bottom, #4f46e5, #a855f7);
            border-radius: 0.25rem;
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .url-example {
            background-color: #f8fafc;
            border-left: 3px solid #4f46e5;
            padding: 1rem;
            margin: 1rem 0;
            font-family: monospace;
        }
        .url-component {
            color: #4f46e5;
            font-weight: 500;
        }
        .footer {
            background-color: #1a202c;
            color: #e2e8f0;
        }
        .footer a:hover {
            color: #a0aec0;
            text-decoration: underline;
        }
        .mermaid {
            background-color: white;
            padding: 1.5rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-4">Java网络编程</h1>
            <h2 class="text-2xl md:text-3xl font-semibold mb-6">URL与HttpURLConnection详解</h2>
            <p class="text-xl opacity-90 max-w-3xl mx-auto">
                探索Java中强大的网络通信工具，掌握URL处理和HTTP连接的核心技术
            </p>
            <div class="mt-8 flex justify-center space-x-4">
                <a href="#url-section" class="px-6 py-3 bg-white text-indigo-600 font-medium rounded-lg hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-link mr-2"></i>URL详解
                </a>
                <a href="#http-section" class="px-6 py-3 bg-indigo-700 text-white font-medium rounded-lg hover:bg-indigo-800 transition duration-300">
                    <i class="fas fa-network-wired mr-2"></i>HttpURLConnection
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- URL Section -->
        <section id="url-section" class="mb-16">
            <div class="mb-8">
                <h3 class="text-3xl font-bold mb-6 text-gray-800 section-title">URL (统一资源定位符)</h3>
                <p class="text-lg text-gray-700 mb-6">
                    统一资源定位符（Uniform Resource Locator）是指向互联网资源的指针。Java提供了URL API，方便我们进行网络通信。
                </p>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-code mr-2"></i>URL格式
                        </h4>
                        <div class="url-example mb-6">
                            <span class="url-component">protocol</span> :// <span class="url-component">hostname</span>[:<span class="url-component">port</span>] / <span class="url-component">path</span> /[?<span class="url-component">query</span>]
                        </div>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="url-example">
                                <a href="http://localhost:8080/day27/regitser.html" class="text-blue-600 hover:underline" target="_blank">
                                    http://localhost:8080/day27/regitser.html
                                </a>
                            </div>
                            <div class="url-example">
                                <a href="http://localhost:8080/day28/RegisterServlet?username=123&password=123" class="text-blue-600 hover:underline" target="_blank">
                                    http://localhost:8080/day28/RegisterServlet?username=123&password=123
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- URL Creation Section -->
            <div class="mb-12">
                <h4 class="text-2xl font-bold mb-6 text-gray-800 section-title">URL的创建方式</h4>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <!-- Method 1 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                        <div class="p-6">
                            <div class="flex items-center mb-3">
                                <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                                    <span class="text-indigo-600 font-bold">1</span>
                                </div>
                                <h5 class="text-lg font-semibold">URL(String url)</h5>
                            </div>
                            <p class="text-gray-600 mb-4">url代表一个绝对地址，URL对象直接指向这个资源</p>
                            <div class="code-block">
                                <button class="code-copy" title="Copy code">
                                    <i class="far fa-copy"></i>
                                </button>
                                <pre><code>URL urll = new URL("http://www.baidu.com/qa/index.html");</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Method 2 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                        <div class="p-6">
                            <div class="flex items-center mb-3">
                                <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                                    <span class="text-indigo-600 font-bold">2</span>
                                </div>
                                <h5 class="text-lg font-semibold">URL(URL baseURL, String relativeURL)</h5>
                            </div>
                            <p class="text-gray-600 mb-4">其中，baseURL代表绝对地址，relativeURL代表相对地址</p>
                            <div class="code-block">
                                <button class="code-copy" title="Copy code">
                                    <i class="far fa-copy"></i>
                                </button>
                                <pre><code>URL urll = new URL("http://www.baidu.com");
URL lib = new URL(urll, "qa/index.html");</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Method 3 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                        <div class="p-6">
                            <div class="flex items-center mb-3">
                                <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                                    <span class="text-indigo-600 font-bold">3</span>
                                </div>
                                <h5 class="text-lg font-semibold">URL(String protocol, String host, String file)</h5>
                            </div>
                            <p class="text-gray-600 mb-4">protocol代表通信协议，host代表主机名，file代表文件名</p>
                            <div class="code-block">
                                <button class="code-copy" title="Copy code">
                                    <i class="far fa-copy"></i>
                                </button>
                                <pre><code>new URL("http", "www.baidu.com", "/qa/index.html");</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Method 4 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                        <div class="p-6">
                            <div class="flex items-center mb-3">
                                <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                                    <span class="text-indigo-600 font-bold">4</span>
                                </div>
                                <h5 class="text-lg font-semibold">URL(String protocol, String host, int port, String file)</h5>
                            </div>
                            <p class="text-gray-600 mb-4">与第三种类似，但可以指定端口号</p>
                            <div class="code-block">
                                <button class="code-copy" title="Copy code">
                                    <i class="far fa-copy"></i>
                                </button>
                                <pre><code>URL lib = new URL("http", "www.baidu.com", 80, "/test/test.asp");</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- URL Examples -->
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
                <!-- Example 1 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-info-circle mr-2"></i>案例一：获取URL的基本信息
                        </h4>
                        <div class="mb-4">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782385698-3a3e2174-8b14-4a2c-8477-f4c7ec418c4d.png" 
                                 alt="URL基本信息获取示例" 
                                 class="w-full h-auto rounded-lg border border-gray-200">
                        </div>
                        <p class="text-gray-600">
                            此示例展示了如何使用URL类获取URL的各个组成部分，包括协议、主机名、端口号、路径等。
                        </p>
                    </div>
                </div>
                
                <!-- Example 2 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-image mr-2"></i>案例二：使用URL获取网络资源图片
                        </h4>
                        <div class="mb-4">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782385946-2d0d211e-4802-4b02-a63c-0b472d134065.png" 
                                 alt="URL获取图片示例" 
                                 class="w-full h-auto rounded-lg border border-gray-200">
                        </div>
                        <p class="text-gray-600 mb-2">
                            <i class="fas fa-external-link-alt mr-2 text-blue-500"></i>
                            <a href="http://i9.qhimg.com/dr/270_500_/t01628b7986e6a845b1.jpg" class="text-blue-600 hover:underline" target="_blank">
                                示例图片下载路径
                            </a>
                        </p>
                        <p class="text-gray-600">
                            此示例展示了如何使用URL类从网络上下载图片资源并保存到本地。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- HttpURLConnection Section -->
        <section id="http-section" class="mb-16">
            <div class="mb-8">
                <h3 class="text-3xl font-bold mb-6 text-gray-800 section-title">HttpURLConnection</h3>
                <p class="text-lg text-gray-700 mb-6">
                    支持HTTP特定功能的URLConnection。HttpURLConnection是Java的标准类，继承自URLConnection，可用于向指定网站发送GET请求、POST请求。
                </p>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-exchange-alt mr-2"></i>与URL对象的关系
                        </h4>
                        <div class="code-block mb-4">
                            <button class="code-copy" title="Copy code">
                                <i class="far fa-copy"></i>
                            </button>
                            <pre><code>public URLConnection openConnection() throws IOException</code></pre>
                        </div>
                        <p class="text-gray-600">
                            返回一个URLConnection对象，它表示到URL所引用的远程对象的连接。
                        </p>
                    </div>
                </div>
            </div>

            <!-- HttpURLConnection Examples -->
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <!-- Example 1 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-download mr-2"></i>案例一：下载图片并使用HttpUrlConnection
                        </h4>
                        <div class="mb-4">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692782386200-6b2c1dfe-847c-435c-bf16-841673a9a55a.png" 
                                 alt="HttpURLConnection下载图片示例" 
                                 class="w-full h-auto rounded-lg border border-gray-200">
                        </div>
                        <p class="text-gray-600">
                            此示例展示了如何使用HttpURLConnection建立HTTP连接并从网络上下载图片资源。
                        </p>
                    </div>
                </div>
                
                <!-- Example 2 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                    <div class="p-6">
                        <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                            <i class="fas fa-memory mr-2"></i>案例二：采用内存流优化上述程序
                        </h4>
                        <div class="mb-4">
                            <div class="mermaid">
                                graph TD
                                    A[URL.openStream] --> B[InputStream]
                                    B --> C[ByteArrayOutputStream]
                                    C --> D[一次性写入文件]
                                    C -.-> E[内存操作更快]
                            </div>
                        </div>
                        <p class="text-gray-600">
                            使用ByteArrayOutputStream先将数据写入到内存中，然后再一次性写到目标文件中，这种方法可以提升IO效率。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Concept Relationship -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden card">
                <div class="p-6">
                    <h4 class="text-xl font-semibold mb-4 text-indigo-600">
                        <i class="fas fa-project-diagram mr-2"></i>核心概念关系
                    </h4>
                    <div class="mermaid">
                        graph LR
                            A[URL] -->|创建| B[URLConnection]
                            B -->|特定于HTTP| C[HttpURLConnection]
                            C --> D[GET/POST请求]
                            C --> E[设置请求头]
                            C --> F[获取响应码]
                            A --> G[获取资源]
                            G --> H[InputStream]
                            H --> I[本地文件/内存]
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="footer py-8 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium">技术小馆</h3>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" target="_blank" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });

        // Copy code functionality
        document.querySelectorAll('.code-copy').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.nextElementSibling;
                const range = document.createRange();
                range.selectNode(codeBlock);
                window.getSelection().removeAllRanges();
                window.getSelection().addRange(range);
                document.execCommand('copy');
                window.getSelection().removeAllRanges();
                
                // Change icon temporarily to indicate copy
                const icon = button.querySelector('i');
                const originalClass = icon.className;
                icon.className = 'fas fa-check';
                setTimeout(() => {
                    icon.className = originalClass;
                }, 2000);
            });
        });
    </script>
</body>
</html>
```